#ifndef DOMTREEPROPERTIES_H
#define DOMTREEPROPERTIES_H

#include <QString>
#include <QMap>
#include <QDomNode>
#include <QIcon>

#define NODE_TYPE_DEFAULT 0

enum eNODE_TEXT_PROP
{
    NO_TEXT,       //! Show nothing
    NODE_NAME,     //! Name of node
    NODE_VALUE,    //! Value of node
    NODE_TYPE,     //! Type of node
    ATTR_VALUE,     //! Attribute Value (Elements only)
    ATTR_NAME_VALUE     //! Attribute Name and Value (Elements only)
};
struct NodeTextProperty
{
    eNODE_TEXT_PROP eTextProp;
    QStringList propPrams;
    NodeTextProperty(eNODE_TEXT_PROP prop,
                     QStringList parms = QStringList())
        : eTextProp(prop), propPrams(parms){}
};

class NodeTextFactory
{
public:

    NodeTextFactory(NodeTextProperty);

    void setTextProperty(NodeTextProperty textProp){mNodeTextProp = textProp;}
    virtual QString displayText(const QDomNode &node, bool flatTextElements = false);

protected:
    NodeTextProperty mNodeTextProp;
};


enum eNODE_ICON_PROP
{
    NO_ICON,          //! Show nothing
    NODE_TYPE_ICON,  //! Node type (built in)
    MANUAL_ICON,        //! Fix user defined icon
    TAG_NAME_AUTO_ICON  //!
};
struct NodeIconProperty
{
    eNODE_ICON_PROP eIconProp;
    QStringList propPrams;
    NodeIconProperty(eNODE_ICON_PROP prop,
                     QStringList parms = QStringList())
        : eIconProp(prop), propPrams(parms){}
};

class NodeIconFactory
{
public:

    NodeIconFactory(NodeIconProperty);

    void setIconProperty(NodeIconProperty iconProp){mNodeIconProp = iconProp;}
    virtual QIcon displayIcon(const QDomNode &node);

protected:
    NodeIconProperty mNodeIconProp;
};

class DomTreeProperties
{
public:
    DomTreeProperties();
    ~DomTreeProperties();

    int columnCount(){return mHeaderLabels.size();}

    void setHeaderLabel(int column, QString text);
    void setTextProperty(int column, int type,
                         NodeTextProperty prop);
    void setIconProperty(int column, int type,
                         NodeIconProperty prop);
    void setNodeTypeVisible(QDomNode::NodeType type, bool visible);
    bool nodeTypeVisible(QDomNode::NodeType type);

    bool flatTextElements(){return mFlatTextElements;}
    void setFlatTextElements(bool flat){mFlatTextElements = flat;}

    QStringList headerLabels(){return mHeaderLabels;}

    QString nodeDisplayText(int column, const QDomNode &node);
    QIcon nodeDisplayIcon(int column, const QDomNode &node);

private:

    void addColumn();

    bool mFlatTextElements;
    QMap<int, bool> mNodeTypeVisibleMap;
    QStringList mHeaderLabels;
    typedef QMap<int, NodeTextFactory*> tNodeTextMap;
    QList<tNodeTextMap> mNodeTextMapList;
    typedef QMap<int, NodeIconFactory*> tNodeIconMap;
    QList<tNodeIconMap> mNodeIconMapList;
};

#endif // DOMTREEPROPERTIES_H
